﻿/*
使用寄生于window的一个全局变量:
window.E
作为全局静态唯一存储的地方
*/

define(function (require, exports, module) {
    require('utility/eventproxy.js');
    //Define Global value
    var baseValue = {
        //serviceBaseUrl: "http://192.168.10.3:20501"
        //serviceBaseUrl: "http://localhost:20501"    
        serviceBaseUrl: "http://www.weimargroup.com:2500"
    };

    var globalConfig = Backbone.Model.extend({
        //Define global event
        initialize: function () {
            _.bindAll(this, 'onLoginSuccess', 'log');
            EventProxy.bind(EventProxy.Events.loginSuccess, this.onLoginSuccess);
        }
        , log: function (str) {
            console.log(str);
            EventProxy.trigger(EventProxy.Events.log, str);
        }
        , onLoginSuccess: function (e) {
            this.attributes["AuthToken"] = e.Data.Token;
        }
    });

    window.E = new globalConfig(baseValue);
    module.exports = window.E;
});

